package com.thinksns.sociax.photograph.gui.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.thinksns.sociax.android.R;
import com.thinksns.sociax.photograph.model.PhotographModel;

import java.util.List;

/**
 * Description
 @author Linsr
 */

public class WorksAdapter extends RecyclerView.Adapter<WorksAdapter.WorksHolder> {
    private Context mContext;
    private List<PhotographModel> mList;

    public WorksAdapter(Context context, List<PhotographModel> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public WorksHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_works, parent, false);//
        return new WorksHolder(view);
    }

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }

    @Override
    public void onBindViewHolder(WorksHolder holder, int position) {
        PhotographModel model = mList.get(position);
        int width = model.getWidth();
        int height = model.getHeight();

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width,height);
        holder.iv.setLayoutParams(params);
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    class WorksHolder extends RecyclerView.ViewHolder {

        private ImageView iv;
        private TextView tv;

        public WorksHolder(View itemView) {
            super(itemView);
            iv = (ImageView) itemView.findViewById(R.id.item_works_iv);
            tv = (TextView) itemView.findViewById(R.id.item_words_tv);
        }
    }

}
